/**
 * 暂无数据
 */

import * as React from 'react';
import { View, ImageSourcePropType, ImageStyle, ViewStyle } from 'react-native';

import styles from './style';
import FastImage from '../FastImage';
import { empty } from '../../constant/resource';
import navigator from '../../util/navigator';
import { getRouteType, RouteType } from '../../config/route';
import CustomText from '../Text';

export default ({
  emptyDesc,
  icon = empty,
  iconStyle = {},
  style
}: {
  emptyDesc: string;
  icon?: ImageSourcePropType;
  iconStyle?: ImageStyle;
  style?: ViewStyle;
}): React.ReactElement => {
  const currentRoute = navigator.getCurrentRoute();
  const routeType = getRouteType(currentRoute.routeName);
  if (routeType === RouteType.LandScape) {
    return (
      <View style={[styles.container, style]}>
        <FastImage source={empty} style={styles.empty} />
        <CustomText style={styles.desc}>{emptyDesc}</CustomText>
      </View>
    );
  }
  return (
    <View style={[styles.portraitContainer, style]}>
      <FastImage
        source={icon}
        style={[styles.portraitIcon, iconStyle]}
        resizeMode="contain"
      />
      <CustomText style={styles.portraitDesc}>{emptyDesc}</CustomText>
    </View>
  );
};
